/*
 *  txdnet.cn tonydon
 * 
 */
package cn.txdnet.txcms.query;

import cn.txdnet.txcms.dict.BooleanType;
import txdnet.util.StaticMark;

/**
 *
 * @author txdnet
 */
public class ViewInfoQuery extends BaseQuery {

    private static final long serialVersionUID = 7259645759900506726L;
    private Long infoid;
    private Long currtime;
    private Byte pubstate;
    private Byte infotype;
    private Integer cataloglevel;
    private Integer cid;
    private Byte orderByHitnum; // 是否使用hitnum排序
    private Byte useSummary;    // 是否使用摘要字段
    private Integer tagid;  // tag id

    @Override
    public void filter() {
        this.currtime = System.currentTimeMillis();
        this.pubstate = BooleanType.TRUE.getValue();
        // 防止大数据读取
        if (this.getListsize() == null || this.getListsize() > 50) {
            this.setListsize(20);
        }
    }

    /**
     * @return the infoid
     */
    public Long getInfoid() {
        return infoid;
    }

    /**
     * @param infoid the infoid to set
     */
    public void setInfoid(Long infoid) {
        this.infoid = infoid;
    }

    /**
     * @return the currtime
     */
    public Long getCurrtime() {
        return currtime;
    }

    /**
     * @param currtime the currtime to set
     */
    public void setCurrtime(Long currtime) {
        this.currtime = currtime;
    }

    /**
     * @return the pubstate
     */
    public Byte getPubstate() {
        return pubstate;
    }

    /**
     * @param pubstate the pubstate to set
     */
    public void setPubstate(Byte pubstate) {
        this.pubstate = pubstate;
    }

    /**
     * @return the infotype
     */
    public Byte getInfotype() {
        return infotype;
    }

    /**
     * @param infotype the infotype to set
     */
    public void setInfotype(Byte infotype) {
        this.infotype = infotype;
    }

    /**
     * @return the cataloglevel
     */
    public Integer getCataloglevel() {
        return cataloglevel;
    }

    /**
     * @param cataloglevel the cataloglevel to set
     */
    public void setCataloglevel(Integer cataloglevel) {
        this.cataloglevel = cataloglevel;
    }

    /**
     * @return the cid
     */
    public Integer getCid() {
        return cid;
    }

    /**
     * @param cid the cid to set
     */
    public void setCid(Integer cid) {
        this.cid = cid;
    }

    /**
     * @return the orderByHitnum
     */
    public Byte getOrderByHitnum() {
        return orderByHitnum;
    }

    /**
     * @param orderByHitnum the orderByHitnum to set
     */
    public void setOrderByHitnum(Byte orderByHitnum) {
        this.orderByHitnum = orderByHitnum;
    }

    /**
     * @return the useSummary
     */
    public Byte getUseSummary() {
        return useSummary;
    }

    /**
     * @param useSummary the useSummary to set
     */
    public void setUseSummary(Byte useSummary) {
        this.useSummary = useSummary;
    }

    /**
     * @return the tagid
     */
    public Integer getTagid() {
        return tagid;
    }

    /**
     * @param tagid the tagid to set
     */
    public void setTagid(Integer tagid) {
        this.tagid = tagid;
    }

    /**
     * 用于缓存Key
     *
     * @return
     */
    public String getCacheKey() {
        StringBuilder sb = new StringBuilder();
        if (infoid != null) {
            sb.append("infoid=").append(infoid);
        }
        if (infotype != null) {
            sb.append("t=").append(infotype).append(StaticMark.CHAR_COMMA);
        }
        if (cid != null) {
            sb.append("cid=").append(cid).append(StaticMark.CHAR_COMMA);
        }
        if (orderByHitnum != null) {
            sb.append("ord=").append(orderByHitnum).append(StaticMark.CHAR_COMMA);
        }
        if (useSummary != null) {
            sb.append("summ=").append(useSummary).append(StaticMark.CHAR_COMMA);
        }
        if (tagid != null) {
            sb.append("tagid=").append(tagid).append(StaticMark.CHAR_COMMA);
        }
        if (infoid == null) {
            if (rownum != null) {
                sb.append("rn=").append(rownum).append(StaticMark.CHAR_COMMA);
            }
            if (crow != null) {
                sb.append("cr=").append(crow).append(StaticMark.CHAR_COMMA);
            }
            if (listsize != null) {
                sb.append("ls=").append(listsize);
            }
        }
        return sb.toString();
    }
}
